#include "internal.h"

struct sched_entity *__pick_root_entity(struct cfs_rq *cfs_rq)
{
    struct rb_node *root = cfs_rq->tasks_timeline.rb_root.rb_node;

    if (!root)
        return NULL;

    return __node_2_se(root);
}

static inline bool entity_before(const struct sched_entity *a,
                                 const struct sched_entity *b)
{
    /*
     * Tiebreak on vruntime seems unnecessary since it can
     * hardly happen.
     */
    return (s64)(a->deadline - b->deadline) < 0;
}

static inline bool __entity_less(struct rb_node *a, const struct rb_node *b)
{
	return entity_before(__node_2_se(a), __node_2_se(b));
}

static inline s64 entity_key(struct cfs_rq *cfs_rq, struct sched_entity *se)
{
    return (s64)(se->vruntime - cfs_rq->min_vruntime);
}
